package top.wuyang.trywork.controller;


import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import top.wuyang.trywork.base.PageBean;
import top.wuyang.trywork.base.R;
import top.wuyang.trywork.entity.TbCpu;
import top.wuyang.trywork.service.TbCpuService;
import top.wuyang.trywork.vo.PageVO;

@RestController
@RequestMapping("/cpu")
@RequiredArgsConstructor
public class TbCpuController {
    private final TbCpuService tbCpuService;

    // 查询
    @GetMapping("/queryAll")
    public R<PageVO<TbCpu>> queryAll(PageBean pageBean, TbCpu tbCpu) {
        return tbCpuService.queryPage(pageBean, tbCpu);
    }

    // 主键查询
    @GetMapping("/{id}")
    public R<TbCpu> queryById(@PathVariable("id") Integer id) {
        return tbCpuService.queryById(id);
    }

    // 添加
    @PostMapping("")
    public R<String> insert(@RequestBody TbCpu tbCpu) {
        return tbCpuService.insert(tbCpu);
    }

    // 修改
    @PutMapping("")
    public R<String> update(@RequestBody TbCpu tbCpu) {
        return tbCpuService.update(tbCpu);
    }

    @DeleteMapping("/{id}")
    public R<String> delete(@PathVariable("id") Integer id) {
        return tbCpuService.delete(id);
    }


}
